<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Thor.Models.SingleDayCalendar>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script type="text/javascript">

        function scrollToCurrentCalendarEntry() {
            var currentCalendarEntry = document.getElementById("currentCalendarEntry");
            if (currentCalendarEntry != null) {
                currentCalendarEntry.scrollIntoView(true);
            }
        }

        window.onload = scrollToCurrentCalendarEntry;
    </script>

    <p>
        <img alt="" src="..\..\Content\Logo.jpg" />
    </p>
    <fieldset>
        <legend>calendar</legend>
        <% if (!string.IsNullOrEmpty(Model.Message))
           {%>
           <p>
           <%= Html.Encode(Model.Message.ToLower()) %>
           </p>
        <%} %>
        <p>
            <strong>resource:</strong>
            <%= Html.Encode(Model.Name) %>
        </p>
        <p>
            <strong>date:</strong>
            <%= Html.Encode(Model.Timestamp.ToLower()) %>
        </p>
        <p>
            <strong>time zone:</strong>
            <%= Html.Encode(Model.Timezone.ToLower()) %>
        </p>
        <table>
            <% foreach (var entry in Model.Entries)
               { %>
            <tr>
                <% if (entry.IsCurrent)
                   {
                    %>
                <td class="currentCalendarEntry">
                    <%= Html.ActionLink(entry.Time.ToShortTimeString().ToLower(), "Book", entry) %>
                </td>                    
                    <%} 
                   else
                   { %>
                <td class="calendarEntry">
                    <%= Html.ActionLink(entry.Time.ToShortTimeString().ToLower(), "Book", entry) %>
                </td>                    
                <%}

                 if (entry.Available)
                   {
                       if (entry.OffHours)
                       {
                           if (entry.IsCurrent)
                           {%>
                <td class="offHoursCalendarEntry" id="currentCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <% }
                           else
                           {
                %>
                <td class="offHoursCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <%}
                       }
                       else
                       {
                           if (entry.IsCurrent)
                           {
                %>
                <td class="availableCalendarEntry" id="currentCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <%
                    }
                               else
                               { 
                %>
                <td class="availableCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <%
                    }
                           }
                   }
                   else
                   {
                       if (entry.IsCurrent)
                       {
                %>
                <td class="busyCalendarEntry" id="currentCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <%
                    }
                       else
                       {
                %>
                <td class="busyCalendarEntry">
                    <%=Html.Encode(entry.DisplayText)%>
                </td>
                <%
                    }
                   } %>
            </tr>
            <%} %>
        </table>
    </fieldset>
</asp:Content>
